package miku.firstgame.model.proxy
{
	import miku.firstgame.model.Me;
	import miku.firstgame.model.User;

	import org.puremvc.as3.patterns.facade.Facade;

	public class ProxyHelper
	{
		private static var connectionProxy:ConnectionProxy;
		private static var lobbyProxy:LobbyProxy;

		public function ProxyHelper()
		{
		}

		public static function send(data:Object):void
		{
			if (connectionProxy == null)
			{
				connectionProxy = Facade.getInstance().retrieveProxy(ConnectionProxy.NAME) as ConnectionProxy;
			}
			connectionProxy.send(data);
		}

		public static function addUser(user:User):void
		{
			if (null == lobbyProxy)
			{
				lobbyProxy = Facade.getInstance().retrieveProxy(LobbyProxy.NAME) as LobbyProxy;
			}
			lobbyProxy.addUser(user);
		}

		public static function getUser(id:int):User
		{
			var user:User;
			if (null == lobbyProxy)
			{
				lobbyProxy = Facade.getInstance().retrieveProxy(LobbyProxy.NAME) as LobbyProxy;

			}
			user = lobbyProxy.getUser(id);
//			if(null == user)
//			{
//				user = Me.Instace.
//			}
			return user;
		}
	}
}
